package com.xiyoufang.club.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xiyoufang.aij.core.AppConfig;
import com.xiyoufang.aij.core.B;
import com.xiyoufang.aij.core.ResponseFactory;
import com.xiyoufang.aij.room.hero.Hero;
import com.xiyoufang.aij.room.hero.HeroManager;
import com.xiyoufang.aij.room.response.CreateTableEventResponse;
import com.xiyoufang.aij.room.table.Table;
import com.xiyoufang.aij.room.table.TableManager;
import com.xiyoufang.club.bean.RoomInfo;
import com.xiyoufang.club.entity.Club;
import com.xiyoufang.club.entity.ClubMembers;
import com.xiyoufang.club.entity.ClubUserIntegral;
import com.xiyoufang.club.mateDate.ProtocalRegulation;
import com.xiyoufang.club.pojo.Account;
import com.xiyoufang.club.pojo.SystemConfig;
import com.xiyoufang.club.pojo.UserInfo;
import com.xiyoufang.club.repository.*;
import com.xiyoufang.club.response.JMessageProtocalRes;
import com.xiyoufang.club.service.IClubService;
import com.xiyoufang.club.utils.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;
import org.tio.core.Tio;
import org.tio.websocket.common.WsResponse;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class ClubServiceImpl implements IClubService {

    //    private static final Logger log = Logger.getLogger(ClubServiceImpl.class);
    private final UserSessionMap userSessionMap = UserSessionMap.getInstance();
    private final ClubSessionMap clubSessionMap = ClubSessionMap.getInstance();
    private final UserMap userMap = UserMap.getInstance();

    @Autowired
    private JpaRepository clubMembersRepository;
    @Autowired
    private ClubRepository clubRepository;
    @Autowired
    private AccountRepository accountRepository;

    @Autowired
    private ClubUserIntegralRepository clubUserIntegralRepository;
    @Autowired
    private UserInfoRepository userInfoRepository;
    @Autowired
    private SystemConfigRepository systemConfigRepository;
    @Autowired
    private ClubComponent clubComponent;


    @Override
    public void receiveCode(String paramString) {

    }

    @Override
    public JMessageProtocalRes createClub(String inJson) {
        JSONObject jsonObject = JSON.parseObject(inJson);
        String userId = jsonObject.getString("userId");
        JMessageProtocalRes res = new JMessageProtocalRes();
        res.setResultCode(ProtocalRegulation.CREATE_CLUB_SUCCESS);
        res.setContent("未知错误!");


        UserInfo userInfo = this.userInfoRepository.findByUserId(userId);
        if (userInfo == null) {
            res.setContent("未知错误!");
        }
        JSONObject parameter = jsonObject;
        int gameCode = parameter.getIntValue("gameCode");
        String clubName = parameter.getString("clubName");
        String gameRules = parameter.getString("gameRules");
        Integer gameRulesNum = parameter.getInteger("gameRulesNum");
        Integer beginIntegral = Integer.valueOf(parameter.getInteger("beginIntegral") == null ? 0 : parameter.getInteger("beginIntegral").intValue());
        if (this.clubRepository.getClubByName(clubName) != null) {
            res.setResult(Boolean.valueOf(false));
            res.setResultInfo("该俱乐部名字已经存在!");

        } else {
            JSONObject clubConf = getClubConf();

            boolean isAgentCreateClub = clubConf.getIntValue(ClubEnum.CLUB_CONFIG_KEY.IS_AGENT_CREATE_CLUB.getKey()) != 0;
            int createClubCardNum = clubConf.getIntValue(ClubEnum.CLUB_CONFIG_KEY.CREATE_CLUB_CARD_NUM.getKey());

            int clubLimit = clubConf.getIntValue(ClubEnum.CLUB_CONFIG_KEY.CLUB_LIMIT.getKey());
            if (isAgentCreateClub) {
                Account account = this.accountRepository.getAccountByUserId(userId);
                if (account == null) {
                    res.setResultInfo("成为代理才能创建俱乐部!");
                    //res.setContent(GsonUtils.beanToJson(outJson).trim());
                    return res;
                }
            }
//            if (userInfo.getRoomCardNum().intValue() < createClubCardNum) {
//                res.setResultInfo("您必须有至少" + createClubCardNum + "房卡才能建俱乐部!");
//                // res.setContent(GsonUtils.beanToJson(outJson).trim());
//                return res;
//            }
            if (clubLimit > 0) {
                int num = this.clubRepository.findCreateAndJoinClub(userId).size();
                if (num >= clubLimit) {
                    res.setResultInfo("创建和加入的俱乐部数量不能超过" + clubLimit + "!");
                    // res.setContent(GsonUtils.beanToJson(outJson).trim());
                    return res;
                }
            }
            Integer clubId = this.clubComponent.getClubId();
            if (clubId == null) {
                res.setResult(Boolean.valueOf(false));
                res.setResultInfo("俱乐部ID已满");

            } else {
                Club club = new Club();
                club.setClubId(clubId);
                club.setName(clubName);
                // club.setNickName(inJson.nickname);
                club.setUserId(userId);
                // club.setHeadImage(inJson.headimgurl);
                club.setNumber(Integer.valueOf(1));
                club.setState(Integer.valueOf(1));
                club.setRoomCardNum(Integer.valueOf(0));
                club.setBeginCsLimit(Integer.valueOf(parameter.getInteger("beginCsLimit") == null ? 0 : parameter.getInteger("beginCsLimit").intValue()));
                club.setRemarks("");
                club.setNotice("");
                club.setAutoTableNum(Integer.valueOf(parameter.getInteger("autoTableNum") == null ? 2 : parameter.getInteger("autoTableNum").intValue()));
                club.setDeductCardUserId(Integer.valueOf(0));
                club.setJoinIntegralLimit(Integer.valueOf(parameter.getInteger("joinIntegralLimit") == null ? 100 : parameter.getInteger("joinIntegralLimit").intValue()));
                club.setIsNeg(Integer.valueOf(parameter.getInteger("isNeg") == null ? 1 : parameter.getInteger("isNeg").intValue()));
                club.setCsQuJian(parameter.getString("csQuJian"));

                club.setEndIntegralLimit(Integer.valueOf(parameter.getInteger("endIntegralLimit") == null ? 10 : parameter.getInteger("endIntegralLimit").intValue()));
                club.setTaxationType(Integer.valueOf(1));
                club.setClubType(Integer.valueOf(parameter.getInteger("clubType") == null ? 1 : parameter.getInteger("clubType").intValue()));
                club.setRebateType(Integer.valueOf(club.getClubType().intValue() >= 2 ? 1 : 0));
                club.setClubSet(parameter.getString("clubSet") == null ? "" : parameter.getString("clubSet"));

                club.setPerPersonTaxation(Integer.valueOf(0));
                club.setWinnerTaxation(Integer.valueOf(0));
                club.setPerPersonTaxationRate("0");
                club.setWinnerTaxationRate("0");
                club.setCreateTime(new Date());
                club.setUpdateTime(new Date());
                if (StringUtils.isNotEmpty(gameRules)) {
                    if (gameRulesNum != null) {
                        List<String> ruleList = new ArrayList();
                        for (int i = 0; i < gameRulesNum.intValue(); i++) {
                            ruleList.add(gameRules);
                        }
                        club.setGameInfo(ruleList.toString());
                    } else {
                        club.setGameInfo(gameRules);
                    }
                }
                this.clubRepository.saveAndFlush(club);
                if (club.getId().intValue() > 0) {
                    ClubMembers clubMembers = new ClubMembers();
                    clubMembers.setClubId(club.getClubId());
                    clubMembers.setCsDistri("[]");
                    clubMembers.setIsPartner(Integer.valueOf(0));
                    clubMembers.setUserId(Integer.valueOf(userId));
                    // clubMembers.setNickName(inJson.nickname);
                    //  clubMembers.setHeadImage(inJson.headimgurl);
                    clubMembers.setType(Integer.valueOf(1));
                    clubMembers.setTotalCs(Double.valueOf(0.0D));
                    clubMembers.setRemainCs(Double.valueOf(0.0D));
                    clubMembers.setCsPercent(Integer.valueOf(0));
                    clubMembers.setInviteCode(ClubUtils.getMemberInviteCode(clubId.intValue(), userId));
                    clubMembers.setLevel(Integer.valueOf(0));

                    clubMembers.setPUserId(Integer.valueOf(0));
                    clubMembers.setIsFreezing(Integer.valueOf(0));
                    clubMembers.setCreateTime(new Date());
                    clubMembers.setUpdateTime(new Date());
                    clubMembers.setClubCardNum(Integer.valueOf(0));
                    this.clubMembersRepository.saveAndFlush(clubMembers);
                    if ((clubMembers.getId().intValue() > 0) && (this.clubUserIntegralRepository.getClubUserIntegralByUserIdAndClubId(Integer.valueOf(userId), club.getClubId()) == null)) {
                        ClubUserIntegral clubUserIntegral = new ClubUserIntegral();
                        clubUserIntegral.setClubId(club.getClubId());
                        clubUserIntegral.setIntegral(beginIntegral);
                        clubUserIntegral.setType(Integer.valueOf(1));
                        clubUserIntegral.setUserId(Integer.valueOf(userId));
                        clubUserIntegral.setCreateTime(new Date());
                        clubUserIntegral.setUpdateTime(new Date());
                        this.clubUserIntegralRepository.saveAndFlush(clubUserIntegral);

                        res.setResult(Boolean.valueOf(true));
                        res.setResultInfo("成功!");
                        JSONObject jsonObject1 = new JSONObject();
                        jsonObject1.put("club", club);
                        res.setContent(jsonObject1.toJSONString());
                    }
                }
            }
        }
        //res.setContent(GsonUtils.beanToJson(res).trim());
        return res;
    }

    @Override
    public void findClubById(String paramString) {
//        JMessageProtocalRes res = new JMessageProtocalRes();
//
//        res.setResult(Boolean.valueOf(false));
//        res.setResultInfo("未知错误!");
//        res.setResultCode(ProtocalRegulation.MY_CLUB_SUCCESS);
////        int userId = Integer.valueOf(inJson.userId).intValue();
//        JSONObject jsonObject = JSON.parseObject(paramString);
//        String userId = jsonObject.getString("userId");
//        int isNew = inJson.isNew == null ? 0 : inJson.isNew.intValue();
//        if (isNew == 0)
//        {
//            List<Club> createClubList = this.clubRepository.findClubByUserId(userId);
//            List<Club> joinClubList = this.clubRepository.findJoinClubByUserId(userId);
//            for (Club c : createClubList)
//            {
//                ClubMembers clubMembers = this.clubMembersRepository.getClubMembersByClubIdAndUserId(c.getClubId().intValue(), userId);
//                if ((c.getClubType() != null) && (c.getClubType().intValue() >= 2))
//                {
//                    Integer clubIntegral = this.clubUserIntegralRepository.getClubUserIntegralByUserIdAndClubId(c.getClubId(), Integer.valueOf(inJson.userId)).getIntegral();
//                    clubMembers.setIntegral(clubIntegral);
//                }
//                c.setMyClubInfo(clubMembers);
//            }
//            for (Club c : joinClubList)
//            {
//                ClubMembers clubMembers = this.clubMembersRepository.getClubMembersByClubIdAndUserId(c.getClubId().intValue(), userId);
//                if ((c.getClubType() != null) && (c.getClubType().intValue() >= 2))
//                {
//                    Integer clubIntegral = this.clubUserIntegralRepository.getClubUserIntegralByUserIdAndClubId(c.getClubId(), Integer.valueOf(inJson.userId)).getIntegral();
//                    clubMembers.setIntegral(clubIntegral);
//                }
//                c.setMyClubInfo(clubMembers);
//            }
//            JSONObject jsonObject = new JSONObject();
//            jsonObject.put("myCreateClubList", createClubList);
//            jsonObject.put("myJoinClubList", joinClubList);
//            outJson.parameter = jsonObject;
//        }
//        else
//        {
//            List myClubList = this.clubRepository.findAllClubAndMemberByUserId(userId);
//
//            JSONObject jsonObject = new JSONObject();
//            jsonObject.put("myClubList", myClubList);
//            outJson.parameter = jsonObject;
//        }
//        outJson.result = Boolean.valueOf(true);
//        outJson.resultInfo = "����!";
//        res.setContent(GsonUtils.beanToJson(outJson).trim());
//        return res;
        return;
    }

    @Override
    public JMessageProtocalRes findClub(String inJson) {
        JSONObject jsonObject = JSON.parseObject(inJson);
        String userId = jsonObject.getString("userId");
        List<Club> clubByUserId = this.clubRepository.findClubByUserId(userId);
        JMessageProtocalRes res = new JMessageProtocalRes();
        res.setResultCode(ProtocalRegulation.CREATE_CLUB_SUCCESS);
        res.setSubType(1);
        res.setContent(clubByUserId);
        return res;
    }

    @Override
    public JMessageProtocalRes findClubMembersByClub(String paramString) {
        return null;
    }

    @Override
    public JMessageProtocalRes clubRoomInfo(String paramString) {
        JMessageProtocalRes res = new JMessageProtocalRes();
        res.setResult(Boolean.valueOf(true));
        res.setResultInfo("未知错误!");
        res.setResultCode(ProtocalRegulation.CLUB_ROOM_INFO_SUCCESS);
        JSONObject parameter = JSONObject.parseObject(paramString);
        int clubId = parameter.getInteger("clubId").intValue();
        Club club = this.clubRepository.getClubByClubId(Integer.valueOf(clubId));
        if (club == null) {
            res.setResultInfo("无此俱乐部!");
            res.setContent(null);
            return res;
        }
        List<String> romIds = (List) this.clubSessionMap.get(Integer.valueOf(clubId));
        JSONObject jsonObject = new JSONObject();
        List<JSONObject> roomInfoList = new ArrayList();
        if (romIds != null) {
            List<String> templist = new ArrayList();
            for (int i = 0; i < romIds.size(); i++) {
                String romId = (String) romIds.get(i);
                RoomInfo roomInfo = (RoomInfo) this.userSessionMap.get(romId);
                if ((roomInfo != null) && (roomInfo.getClubId() > 0) && (roomInfo.getClubId() == clubId)) {
                    JSONObject j = new JSONObject();
                    setReturnRoomInfo(j, roomInfo);
                    roomInfoList.add(j);
                } else {
                    templist.add(romId);
                }
            }
            if (templist.size() > 0) {
                romIds.removeAll(templist);
            }
        }
        jsonObject.put("roomInfoList", roomInfoList);
        jsonObject.put("clubId", Integer.valueOf(clubId));
        res.setResult(Boolean.valueOf(true));
        res.setResultInfo("成功!");
        res.setContent(jsonObject);
        return res;
    }


    public JSONObject getClubConf() {
        JSONObject clubConf = new JSONObject();

        List<SystemConfig> systemConfigList = this.systemConfigRepository.findSystemConfigByGroup("club");
        for (SystemConfig systemConfig : systemConfigList) {
            clubConf.put(systemConfig.getKey(), systemConfig.getValue());
        }
        return clubConf;
    }

    public void setReturnRoomInfo(JSONObject j, RoomInfo roomInfo) {
        String romId = roomInfo.getRoomId();
        List joinUserList = new ArrayList();
        j.put("roomId", roomInfo.getRoomId());
        j.put("clubId", roomInfo.getClubId());
        j.put("tableNum", roomInfo.getTableNum());
        j.put("gameType", roomInfo.getGameType());
        j.put("playerNum", roomInfo.getPlayerNum());
        j.put("participation", roomInfo.getParticipation());
        j.put("actualParticipation", roomInfo.getActualParticipation());
        j.put("createRoomPlayerId", roomInfo.getCreateRoomPlayerId());
        j.put("isActualGameStart", roomInfo.isActualGameStart());
        j.put("numberOfGames", roomInfo.getNumber_of_games());
        j.put("actualNumberOfGames", roomInfo.getActual_number_of_games());
        j.put("isAARoom", roomInfo.getIsAARoom());
        j.put("limitTime", roomInfo.getLimitTime());
        j.put("isAutoOperation", roomInfo.getIsAutoOperation());
        j.put("deductRoomCard", roomInfo.getDeductRoomCard());
//        if (roomInfo.getGameType() == 105) {
//            FTKRoomInfo ftkRoomInfo = (FTKRoomInfo)this.userSessionMap.get(romId);
//            j.put("underDouble", ftkRoomInfo.getUnderDouble());
//            j.put("isLaiZi", ftkRoomInfo.getIsLaiZi());
//            j.put("isRandom", ftkRoomInfo.getIsRandomTeam());
//            j.put("isBlack", ftkRoomInfo.getIsDarkNight());
//        } else if (roomInfo.getGameType() == 1005) {
//            NhzmjRoomInfo nhzmjRoomInfo = (NhzmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("baoTou", nhzmjRoomInfo.getBaoTou());
//            j.put("fengDingFen", nhzmjRoomInfo.getFengDingFen());
//            j.put("isSanTan", nhzmjRoomInfo.getIsSanTan());
//            j.put("jiLaoQi", nhzmjRoomInfo.getJiLaoQi());
//            j.put("dpOrZiMo", nhzmjRoomInfo.getDpOrZiMo());
//            j.put("duoCaiJiaFan", nhzmjRoomInfo.getDuoCaiJiaFan());
//            j.put("diFen", nhzmjRoomInfo.getDiFen());
//        } else if (roomInfo.getGameType() == 1035) {
//            FzhzmjRoomInfo fzhzmjRoomInfo = (FzhzmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("baoTou", fzhzmjRoomInfo.getBaoTou());
//            j.put("fengDingFen", fzhzmjRoomInfo.getFengDingFen());
//            j.put("isSanTan", fzhzmjRoomInfo.getIsSanTan());
//            j.put("jiLaoQi", fzhzmjRoomInfo.getJiLaoQi());
//            j.put("dpOrZiMo", fzhzmjRoomInfo.getDpOrZiMo());
//            j.put("duoCaiJiaFan", fzhzmjRoomInfo.getDuoCaiJiaFan());
//            j.put("diFen", fzhzmjRoomInfo.getDiFen());
//            j.put("puDi", fzhzmjRoomInfo.getPuDi());
//        } else if (roomInfo.getGameType() == 1045) {
//            NfzhzmjRoomInfo nfzhzmjRoomInfo = (NfzhzmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("baoTou", nfzhzmjRoomInfo.getBaoTou());
//            j.put("fengDingFen", nfzhzmjRoomInfo.getFengDingFen());
//            j.put("isSanTan", nfzhzmjRoomInfo.getIsSanTan());
//            j.put("jiLaoQi", nfzhzmjRoomInfo.getJiLaoQi());
//            j.put("dpOrZiMo", nfzhzmjRoomInfo.getDpOrZiMo());
//            j.put("diFen", nfzhzmjRoomInfo.getDiFen());
//            j.put("duoCaiJiaFan", nfzhzmjRoomInfo.getDuoCaiJiaFan());
//        } else if (roomInfo.getGameType() == 5) {
//            DpmjRoomInfo dpmjRoomInfo = (DpmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("keHuQiDui", dpmjRoomInfo.getKeHuQiDui());
//            j.put("dpOrZiMo", dpmjRoomInfo.getDpOrZiMo());
//        } else if (roomInfo.getGameType() == 1012) {
//            WjmjRoomInfo wjmjRoomInfo = (WjmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("diZhu", wjmjRoomInfo.getDiZhu());
//            j.put("yiFenKeHu", wjmjRoomInfo.getYiFenKeHu());
//            j.put("tianHuJiaFen", wjmjRoomInfo.getTianHuJiaFen());
//        } else if (roomInfo.getGameType() == 2024) {
//            HncsmjRoomInfo mjRoomInfo = (HncsmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("projectIndex", mjRoomInfo.getProjectIndex());
//            j.put("piaoType", mjRoomInfo.getPiaoType());
//            j.put("xianZhuangSuanFen", mjRoomInfo.getXianZhuangSuanFen());
//            j.put("liuLiuShun", mjRoomInfo.getLiuLiuShun());
//            j.put("queYiSe", mjRoomInfo.getQueYiSe());
//            j.put("banBanHu", mjRoomInfo.getBanBanHu());
//            j.put("daSiXi", mjRoomInfo.getDaSiXi());
//            j.put("maType", mjRoomInfo.getMaType());
//            j.put("mCardNum", mjRoomInfo.getmCardNum());
//            j.put("jieJieGao", mjRoomInfo.getJieJieGao());
//            j.put("jiaJiangHu", mjRoomInfo.getJiaJiangHu());
//            j.put("yiZhiHua", mjRoomInfo.getYiZhiHua());
//            j.put("ztSiXi", mjRoomInfo.getZtSiXi());
//            j.put("jiangYiZhiHua", mjRoomInfo.getJiangYiZhiHua());
//            j.put("ztLiuLiuShun", mjRoomInfo.getZtLiuLiuShun());
//            j.put("jinTongYuNv", mjRoomInfo.getJinTongYuNv());
//            j.put("sanTong", mjRoomInfo.getSanTong());
//        } else if (roomInfo.getGameType() == 2012) {
//            WbzzmjRoomInfo mjRoomInfo = (WbzzmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("projectIndex", mjRoomInfo.getProjectIndex());
//            j.put("dpOrZiMo", mjRoomInfo.getDpOrZiMo());
//            j.put("xianZhuangSuanFen", mjRoomInfo.getXianZhuangSuanFen());
//            j.put("keHuQiDui", mjRoomInfo.getKeHuQiDui());
//            j.put("sumOfHongZhong", mjRoomInfo.getSumOfHongZhong());
//            j.put("mCardNum", mjRoomInfo.getMCardNum());
//            j.put("maType", mjRoomInfo.getMaType());
//            j.put("isQiangGangHuEnabled", mjRoomInfo.getIsQiangGangHuEnabled());
//            j.put("huangZhuangHuangGang", mjRoomInfo.getHuangZhuangHuangGang());
//            j.put("isQingHuDouble", mjRoomInfo.getIsQingHuDouble());
//            j.put("isDaHuDouble", mjRoomInfo.getIsDaHuDouble());
//            j.put("isQingHuJiangMa", mjRoomInfo.getIsQingHuJiangMa());
//        } else if (roomInfo.getGameType() == 2026) {
//            LzmjRoomInfo mjRoomInfo = (LzmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("projectIndex", mjRoomInfo.getProjectIndex());
//            j.put("mCardNum", mjRoomInfo.getMCardNum());
//            j.put("maType", mjRoomInfo.getMaType());
//            j.put("daiFeng", mjRoomInfo.getDaiFeng());
//            j.put("isMenQing", mjRoomInfo.getIsMenQing());
//            j.put("fengDingHuShu", mjRoomInfo.getFengDingHuShu());
//        } else if (roomInfo.getGameType() == 56) {
//            NnRoomInfo nnRoomInfo = (NnRoomInfo)this.userSessionMap.get(romId);
//            j.put("roomBankerModel", nnRoomInfo.getRoomBankerModel());
//            j.put("timesRegular", nnRoomInfo.getTimesRegular());
//            j.put("straight", nnRoomInfo.getStraight());
//            j.put("fiveKing", nnRoomInfo.getFiveKing());
//            j.put("sameColor", nnRoomInfo.getSameColor());
//            j.put("threeDouble", nnRoomInfo.getThreeDouble());
//            j.put("boom", nnRoomInfo.getBoom());
//            j.put("fiveSmall ", nnRoomInfo.getFiveSmall());
//            j.put("sameColorStraight", nnRoomInfo.getSameColorStraight());
//            j.put("underScores", nnRoomInfo.getUnderScores());
//            j.put("isCp", nnRoomInfo.getIsCp());
//            j.put("maxBankerTimes", nnRoomInfo.getMaxBankerTimes());
//            j.put("tuiZhuTopBet", nnRoomInfo.getTuiZhuTopBet());
//            j.put("is", nnRoomInfo.getTuiZhuTopBet());
//        } else if (roomInfo.getGameType() == 1033) {
//            HqmjRoomInfo hqmjRoomInfo = (HqmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("isAARoom", hqmjRoomInfo.getIsAARoom());
//            j.put("isChiEnabled", hqmjRoomInfo.getIsChiEnabled());
//            j.put("isQiangGangHuEnabled", hqmjRoomInfo.getIsQiangGangHuEnabled());
//            j.put("isGangKaiDouble", hqmjRoomInfo.getIsGangKaiDouble());
//            j.put("dianPaoType", hqmjRoomInfo.getDianPaoType());
//            j.put("lunZHuang", hqmjRoomInfo.getLunZHuang());
//            j.put("diFen", hqmjRoomInfo.getDiFen());
//            j.put("isSanTan", hqmjRoomInfo.getIsSanTan());
//        } else if (roomInfo.getGameType() == 6) {
//            XzmjRoomInfo xzmjRoomInfo = (XzmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("isSanRenLiangFang", xzmjRoomInfo.getIsSanRenLiangFang());
//            j.put("isHuanSanZhangEnabled", xzmjRoomInfo.getIsHuanSanZhangEnabled());
//            j.put("isHuJiaoZhuanYi", xzmjRoomInfo.getIsHuJiaoZhuanYi());
//            j.put("ziMoType", xzmjRoomInfo.getZiMoType());
//            j.put("isDaiYaoJiu", xzmjRoomInfo.getIsDaiYaoJiu());
//            j.put("isDuanYaoJiu", xzmjRoomInfo.getIsDuanYaoJiu());
//            j.put("isJiangDui", xzmjRoomInfo.getIsJiangDui());
//            j.put("isMenQing", xzmjRoomInfo.getIsMenQing());
//            j.put("isTianDiHu", xzmjRoomInfo.getIsTianDiHu());
//            j.put("isHaiDiLao", xzmjRoomInfo.getIsHaiDiLao());
//            j.put("fengDingHuShu", xzmjRoomInfo.getFengDingHuShu());
//            j.put("dianGangHuaType", xzmjRoomInfo.getDianGangHuaType());
//        } else if (roomInfo.getGameType() == 103) {
//            SkRoomInfo skRoomInfo = (SkRoomInfo)this.userSessionMap.get(romId);
//            j.put("shuangKouType", skRoomInfo.getShuangKouType());
//            j.put("licensingNum", skRoomInfo.getLicensingNum());
//            j.put("shuangMing", skRoomInfo.getShuangMing());
//            j.put("underScores", skRoomInfo.getUnderScores());
//            j.put("boomJl", skRoomInfo.getBoomJl());
//            j.put("winLoseKz", skRoomInfo.getWinLoseKz());
//        } else if (roomInfo.getGameType() == 1013) {
//            NhmjRoomInfo nhmjRoomInfo = (NhmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("playType", nhmjRoomInfo.getPlayType());
//            j.put("shiChang", nhmjRoomInfo.getShiChang());
//            j.put("nhOrXd", nhmjRoomInfo.getNhOrXd());
//        } else if (roomInfo.getGameType() == 1046) {
//            XsmjRoomInfo xsmjRoomInfo = (XsmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("playType", xsmjRoomInfo.getPlayType());
//            j.put("shiChang", xsmjRoomInfo.getShiChang());
//        } else if (roomInfo.getGameType() == 2015) {
//            NbmjRoomInfo nbmjRoomInfo = (NbmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("playType", nbmjRoomInfo.getPlayType());
//            j.put("shiChang", nbmjRoomInfo.getShiChang());
//        } else if (roomInfo.getGameType() == 1047) {
//            FhmjRoomInfo fhmjRoomInfo = (FhmjRoomInfo)this.userSessionMap.get(romId);
//            j.put("playType", fhmjRoomInfo.getPlayType());
//            j.put("shiChang", fhmjRoomInfo.getShiChang());
//        } else if (roomInfo.getGameType() == 108) {
//            PDKRoomInfo pdkRoomInfo = (PDKRoomInfo)this.userSessionMap.get(romId);
//            j.put("handInitCardNum", pdkRoomInfo.getHandInitCardNum());
//            j.put("isShowCardNum", pdkRoomInfo.getIsShowCardNum());
//            j.put("isMustOut", pdkRoomInfo.getIsMustOut());
//            j.put("isMustBlackThree", pdkRoomInfo.getIsMustBlackThree());
//            j.put("iLastOutRule", pdkRoomInfo.getLastOutRule());
//        } else if (roomInfo.getGameType() == 55) {
//            SgRoomInfo sgRoomInfo = (SgRoomInfo)this.userSessionMap.get(romId);
//            j.put("xianJiaTuiZhu", sgRoomInfo.getTuiZhu());
//            j.put("roomBankerModel", sgRoomInfo.getBankerModel());
//            j.put("isTouZi", sgRoomInfo.getIsTouZi());
//            j.put("underScores", sgRoomInfo.getUnderScores());
//        } else if (roomInfo.getGameType() == 78) {
//            NsssRoomInfo nsssRoomInfo = (NsssRoomInfo)this.userSessionMap.get(romId);
//            j.put("underScores", nsssRoomInfo.getUnderScores());
//            j.put("maCards", nsssRoomInfo.getMaCards());
//            j.put("areaCode", nsssRoomInfo.getAreaCode());
//        }
//
//        Iterator var27 = roomInfo.getUserSessions().iterator();
//
//        while(var27.hasNext()) {
//            UserSession userSession = (UserSession)var27.next();
//            JSONObject joinUser = new JSONObject();
//            joinUser.put("userId", userSession.user.getUserId());
//            joinUser.put("nickName", userSession.user.getNickName());
//            joinUser.put("headimgurl", userSession.user.getHeadimgurl());
//            joinUser.put("totalIntegral", userSession.user.getTotalIntegral());
//            joinUserList.add(joinUser);
//        }

        j.put("joinUserList", joinUserList);
    }

    @Override
    public void clubCreateRoom(String paramString) {
        JSONObject jsonObject = JSON.parseObject(paramString);
        String userId = jsonObject.getString("userId");
        Hero hero = HeroManager.getInstance().getHero(userId);

        B b = TableManager.getInstance().create(hero, paramString);
        if (b.b) {
            CreateTableEventResponse response = ResponseFactory.success(CreateTableEventResponse.class, "创建桌子");
            response.setTableNo(((Table) b.m).getTableNo());
            Tio.send(null, WsResponse.fromText(response.toJson(), AppConfig.use().getCharset()));
            return;
        }
    }

}
